home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE25 / EX8.C < prev    next >
C/C++ Source or Header  |  1995-04-23  |  1KB  |  41 lines

  1. #include <genstub.c>
  2.  
  3. // Child thread procedure just displays a message box with information.
  4. DWORD WINAPI ChildThreadProc(HWND hWnd)
  5. {
  6.     TCHAR szBuffer[256];
  7.     wsprintf(szBuffer,
  8.              "Process Handle = %x, ID = %x, Thread: Handle = %x, ID = %x",
  9.              GetCurrentProcess(), GetCurrentProcessId(),
  10.              GetCurrentThread(), GetCurrentThreadId());
  11.     MessageBox( hWnd, szBuffer, "Process/Thread Report", MB_OK );
  12.     ExitThread(TRUE);
  13. }
  14.  
  15. // Main Window Procedure
  16. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  17. {
  18.    switch (uMsg)
  19.    {
  20.          case WM_COMMAND:       // Process menu items.
  21.                switch ( LOWORD( wParam )  )
  22.                {
  23.                   case IDM_TEST:
  24.                   {
  25.                      DWORD dwChildId;
  26.                      CreateThread( NULL, 0, ChildThreadProc, hWnd, 0, &dwChildId );
  27.                   }
  28.                   break;
  29.                   case IDM_EXIT:
  30.                        DestroyWindow( hWnd );
  31.                        break;
  32.                }
  33.          break;
  34.          case WM_DESTROY:
  35.                PostQuitMessage( 0 );
  36.                break;
  37.          default:
  38.                return DefWindowProc( hWnd, uMsg, wParam, lParam );
  39.    }
  40.    return NULL;
  41. }